package com.kangye.enterprise.controller;

import com.kangye.enterprise.entity.*;
import com.kangye.enterprise.service.BannerService;
import com.kangye.enterprise.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: enterprise
 * @description: 轮播图接口
 * @author: 索腾龙
 * @create: 2021-05-27 15:31
 **/

@Controller
public class BannerController {
    @Autowired
    private BannerService bannerService;
    @Autowired
    HttpServletRequest request; //通过注解获取一个request

    //热点配置跳转（李易衡）
    @RequestMapping("/hotspotjump")
    public String hotspotjump(){
        return "hotspot";
    }
    //热点配置表格展示（李易衡）
    @ResponseBody
    @RequestMapping("/hotspot")
    public ViewJsonObject<Map<String,Object>> hotspot(Integer page, Integer limit, String demoReload, String deSelect, Circular circular, BindingResult bindingResult , Integer itemsState){
        return bannerService.hotspot(page,limit,demoReload,deSelect,circular,bindingResult,itemsState);
    }

    //从缓存中获取id（李易衡）
    @RequestMapping("/regionalizaUsers")
    public Integer regionalizaUsers(){
        Users users = (Users) request.getSession().getAttribute("users");
        Integer usersId = users.getUsersId();
        return usersId;
    }

    //取消热门（李易衡）
    @ResponseBody
    @RequestMapping("/cancel")
    public String cancel(Integer circularId){


        Integer code = bannerService.cancel(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.loge(username);
            return "200";
        }else {
            return "201";
        }
    }

    //设置为热门（李易衡）
    @ResponseBody
    @RequestMapping("/setup")
    public String setup(Integer circularId){
        Integer code = bannerService.setup(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.hotloge(username);
            return "200";
        }else {
            return "201";
        }
    }




    //部门跳转（李易衡）
    @RequestMapping("/departjump")
    public String departjump(){
        return "compe";
    }


    //部门表格（李易衡）
    @ResponseBody
    @RequestMapping("/compe")
    public ViewJsonObject<Department> depart(Integer page, Integer limit,String demoReload){
        System.out.println("部门进入controller");
        return bannerService.depart(page,limit,demoReload);
    }

    //批量删除部门（李易衡）
    @ResponseBody
    @RequestMapping("/delCoByIds")
    public ViewJsonObject<Map<String,Object>> delCoByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delCoByIds(list);
    }
    //修改部门（李易衡）
    @ResponseBody
    @RequestMapping("/updcompe")
    public String updcompe(String departmentName,Integer departmentId){
        //修改部门查重（李易衡）
        List<Department> list = bannerService.updCompeRepeat(departmentName);
        if (list.size()>0){

            return "202";
        }else {
            Integer code = bannerService.updcompe(departmentName,departmentId);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.upddeLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }

    //删除部门（李易衡）
    @ResponseBody
    @RequestMapping("/delcompe")
    public String delcompe(Integer departmentId){


        Integer code = bannerService.delcompe(departmentId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.deldeLoge(username);
            return "200";
        }else {
            return "201";
        }
    }

    //添加部门（李易衡）
    @ResponseBody
    @RequestMapping("/addcompe")
    public String addcompe(String departmentName){

        //添加部门查重（李易衡）
        List<Department> list = bannerService.addCompeRepeat(departmentName);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.addcompe(departmentName);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.adddeLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }




    //级别跳转（李易衡）
    @RequestMapping("/leveljump")
    public String leveljump(){
        return "level";
    }

    //级别表格（李易衡）
    @ResponseBody
    @RequestMapping("/level")
    public ViewJsonObject<Rank> level(Integer page, Integer limit,String demoReload){
        return bannerService.level(page,limit,demoReload );
    }
    //修改级别（李易衡）
    @ResponseBody
    @RequestMapping("/updlevel")
    public String updlevel(String rankName,Integer rankId){
        //修改级别查重（李易衡）
        List<Rank> list = bannerService.repeat(rankName);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.updlevel(rankName,rankId);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.updleLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }


    //删除级别（李易衡）
    @ResponseBody
    @RequestMapping("/dellevel")
    public String dellevel(Integer rankId){
        Integer code = bannerService.dellevel(rankId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delleLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //添加级别（李易衡）
    @ResponseBody
    @RequestMapping("/addlevel")
    public String addlevel(String rankName){

        //添加级别查重（李易衡）
        List<Rank> list = bannerService.addrepeat(rankName);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.addlevel(rankName);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.addleLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }


    //批量删除级别
    @ResponseBody
    @RequestMapping("/delLeByIds")
    public ViewJsonObject<Map<String,Object>> delLeByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delLeByIds(list);
    }



    //领域跳转（李易衡）
    @RequestMapping("/fieldjump")
    public String fieldjump(){
        return "field";
    }

    //领域列表（李易衡）
    @ResponseBody
    @RequestMapping("/field")
    public ViewJsonObject<Domoin> field(Integer page, Integer limit,String demoReload){
        return bannerService.field(page,limit,demoReload);
    }

    //修改领域（李易衡）
    @ResponseBody
    @RequestMapping("/updfield")
    public String updfield(String domoinName,Integer domoinId){

        //修改领域查重（李易衡）
        List<Domoin> list = bannerService.updFieldrepeat(domoinName);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.updfield(domoinName,domoinId);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.updfiLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }

    //删除领域（李易衡）
    @ResponseBody
    @RequestMapping("/delfield")
    public String delfield(Integer domoinId){


        Integer code = bannerService.delfield(domoinId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delfiLoge(username);
            return "200";
        }else {
            return "201";
        }
    }

    //批量删除领域
    @ResponseBody
    @RequestMapping("/delFiByIds")
    public ViewJsonObject<Map<String,Object>> delFiByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delFiByIds(list);
    }


    //添加领域（李易衡）
    @ResponseBody
    @RequestMapping("/addfield")
    public String addfield(String domoinName){

        //添加领域查重（李易衡）
        List<Domoin> list = bannerService.addFieldRepeat(domoinName);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.addfield(domoinName);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.addfiLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }


    //精准配（李易衡）
    @RequestMapping("/precisejump")
    public String precisejump(){
        return "precise";
    }

    //精准配列表（李易衡）
    @ResponseBody
    @RequestMapping("/precise")
    public ViewJsonObject<Precise> precise(Integer page, Integer limit,String demoReload){
        return bannerService.precise(page,limit,demoReload);
    }

    //新增精准配（李易衡）
    @ResponseBody
    @RequestMapping("/addprecise")
    public String addprecise(String preciseType,String preciseOption){

        //新增精准配查重（李易衡）
        List<Precise> list = bannerService.addprerepeat(preciseType);
        if (list.size()>0){
            return "202";
        }else {
            Integer code = bannerService.addprecise(preciseType,preciseOption);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.addprLoge(username);
                return "200";
            }else {
                return "201";
            }
        }
    }
    //删除精准配（李易衡）
    @ResponseBody
    @RequestMapping("/delprecise")
    public String delprecise(Integer preciseId){

        Integer code = bannerService.delprecise(preciseId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delprLoge(username);
            return "200";
        }else {
            return "201";
        }
    }

    //批量删除精准配
    @ResponseBody
    @RequestMapping("/delPreByIds")
    public ViewJsonObject<Map<String,Object>> delPreByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delPreByIds(list);
    }


    //修改精准配（李易衡）
    @ResponseBody
    @RequestMapping("/updprecise")
    public String updprecise(Integer preciseId,String preciseType,String preciseOption){

//        List<Precise> list = bannerService.addprerepeat(preciseType);
//        if (list.size()>0){
//            return "202";
//        }else {
        Integer code = bannerService.updprecise(preciseId,preciseType,preciseOption);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.updprLoge(username);
            return "200";
        }else {
            return "201";
        }
//        }
    }


//综合管理
//综合管理
//综合管理
//综合管理
//综合管理
//综合管理

    //通知管理跳转（李易衡）
    @RequestMapping("/notmanjump")
    public String notmanjump(){
        return "notman";
    }
    //通知管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/notman")
    public ViewJsonObject<Map<String,Object>> notman(Integer page, Integer limit,String demoReload,String domoin,String departments,String rank){
        return bannerService.notman(page,limit,demoReload,domoin,departments,rank);
    }

    //批量删除通知
    @ResponseBody
    @RequestMapping("/delNotByIds")
    public ViewJsonObject<Map<String,Object>> delNotByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delNotByIds(list);
    }


    //地区下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selRe")
    public ArrayList<Region> selRe(){
        ArrayList<Region> list = bannerService.selRe();
        return list;
    }

    //领域下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selDo")
    public ArrayList<Domoin> selDo() {
        ArrayList<Domoin> list = bannerService.selDo();
        return list;
    }

    //部门下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selDe")
    public ArrayList<Department> selDe() {
        ArrayList<Department> list = bannerService.selDe();
        return list;
    }

    //级别下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selRa")
    public ArrayList<Rank> selRa() {
        ArrayList<Rank> list = bannerService.selRa();
        return list;
    }

    //项目下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selCi")
    public ArrayList<Project> selCi() {
        ArrayList<Project> list = bannerService.selCi();
        return list;
    }


    //修改通知（李易衡）
    @ResponseBody
    @RequestMapping("/updNotman")
    public String updNotman(Integer circularId ,String circularTitle,String circularLabel,String regionName,String domoinName,String departmentName,String circularContent,String projectName,String rankName){

//        List<Map<String,Object>> list = bannerService.updNotmanrepeat(circularId,circularTitle,circularLabel,regionName,domoinName,departmentName,circularContent,projectName,rankName);
//        if (list.size()>0){
//            return "202";
//        }else {
        //获取部门id（李易衡）
        Integer circularRegionld = bannerService.selRegion(regionName);
        //获取领域id（李易衡）
        Integer circularDomoinld = bannerService.selDomoin(domoinName);
        //获取部门id（李易衡）
        Integer circularDepartmentld = bannerService.seldepartment(departmentName);
        //获取项目id（李易衡）
        Integer circularProjectid = bannerService.selproject(projectName);
        //获取级别id（李易衡）
        Integer circularRankld = bannerService.selrank(rankName);
        //修改通知（李易衡）
        Integer code = bannerService.updNotman(circularId,circularTitle,circularLabel,circularRegionld,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.updnoLoge(username);
            return "200";
        }else {
            return "201";
            // }
        }
    }

    //添加通知（李易衡）
    @ResponseBody
    @RequestMapping("/addNotman")
    public String addNotman(String circularTitle,String circularLabel,String regionName,String domoinName,String departmentName,String circularContent,String projectName,String rankName,Date time){
//        List<Map<String,Object>> list = bannerService.updNotmanrepeat(circularId,circularTitle,circularLabel,regionName,domoinName,departmentName,circularContent,projectName,rankName);
//        if (list.size()>0){
//            return "202";
//        }else {
        //获取部门id（李易衡）
        Integer circularRegionld = bannerService.selRegion(regionName);
        //获取领域id（李易衡）
        Integer circularDomoinld = bannerService.selDomoin(domoinName);
        //获取部门id（李易衡）
        Integer circularDepartmentld = bannerService.seldepartment(departmentName);
        //获取项目id（李易衡）
        Integer circularProjectid = bannerService.selproject(projectName);
        //获取级别id（李易衡）
        Integer circularRankld = bannerService.selrank(rankName);
        //添加通知（李易衡）
        Integer code = bannerService.addNotman(circularTitle,circularLabel,circularRegionld,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld,time);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.addnoLoge(username);
            return "200";
        }else {
            return "201";
            // }
        }
    }


    //删除通知（李易衡）
    @ResponseBody
    @RequestMapping("/delnotman")
    public String delnotman(Integer circularId){
        Integer code = bannerService.delnotman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delnoLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //停用通知（李易衡）
    @ResponseBody
    @RequestMapping("/stopnotman")
    public String stopnotman(Integer circularId){
        Integer code = bannerService.stopnotman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.stopnoLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //政策管理跳转（李易衡）
    @RequestMapping("/polmanjump")
    public String polmanjump(){
        return "polman";
    }
    //政策管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/polman")
    public ViewJsonObject<Map<String,Object>> polman(Integer page, Integer limit,String demoReload,String domoin,String departments,String rank){
        return bannerService.polman(page,limit,demoReload,domoin,departments,rank);
    }

    //批量删除政策
    @ResponseBody
    @RequestMapping("/delPolByIds")
    public ViewJsonObject<Map<String,Object>> delPolByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delPolByIds(list);
    }

    //修改政策（李易衡）
    @ResponseBody
    @RequestMapping("/updPolman")
    public String updPolman(Integer circularId ,String circularTitle,String circularLabel,String domoinName,String departmentName,String circularContent,String projectName,String rankName){
        List<Map<String,Object>> list = bannerService.updPolmanrepeat(circularTitle,circularLabel,domoinName,departmentName,rankName);
        if (list.size()>0){
            return "202";
        }else {
            //获取领域id（李易衡）
            Integer circularDomoinld = bannerService.selDomoin(domoinName);
            //获取部门id（李易衡）
            Integer circularDepartmentld = bannerService.seldepartment(departmentName);
            //获取项目id（李易衡）
            Integer circularProjectid = bannerService.selproject(projectName);
            //获取级别id（李易衡）
            Integer circularRankld = bannerService.selrank(rankName);
            //修改政策（李易衡）
            Integer code = bannerService.updPolman(circularId,circularTitle,circularLabel,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.updpoLoge(username);
                return "200";
            }else {
                return "201";
             }
        }
    }

    //添加政策（李易衡）
    @ResponseBody
    @RequestMapping("/addPolman")
    public String addPolman(String circularTitle, String circularLabel, String domoinName, String departmentName, String circularContent, String projectName, String rankName, Date time){
        List<Map<String,Object>> list = bannerService.updPolmanrepeat(circularTitle,circularLabel,domoinName,departmentName,rankName);
        if (list.size()>0){
            return "202";
        }else {
            //获取领域id
            Integer circularDomoinld = bannerService.selDomoin(domoinName);
            //获取部门id
            Integer circularDepartmentld = bannerService.seldepartment(departmentName);
            //获取项目id
            Integer circularProjectid = bannerService.selproject(projectName);
            //获取级别id
            Integer circularRankld = bannerService.selrank(rankName);
            //添加政策（李易衡）
            Integer code = bannerService.addPolman(circularTitle,circularLabel,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld,time);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.addpoLoge(username);
                return "200";
            }else {
                return "201";
             }
        }
    }


    //删除政策（李易衡）
    @ResponseBody
    @RequestMapping("/delPolman")
    public String delPolman(Integer circularId){
        Integer code = bannerService.delPolman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delpoLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //停用政策（李易衡）
    @ResponseBody
    @RequestMapping("/stopPolman")
    public String stopPolman(Integer circularId){
        Integer code = bannerService.stopPolman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.stoppoLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //公示管理跳转（李易衡）
    @RequestMapping("/pubmanjump")
    public String pubmanjump(){
        return "pubman";
    }
    //公式管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/pubman")
//    public ViewJsonObject<Map<String,Object>> pubman(Integer page, Integer limit,String demoReload,String domoin,String departments){
//        return bannerService.pubman(page,limit,demoReload,domoin,departments);
//    }

    public ViewJsonObject<Map<String,Object>> pubman(Integer page, Integer limit,String demoReload,String domoin,String departments){
        return bannerService.pubman(page,limit,demoReload,domoin,departments);
    }

    //修改公式（李易衡）
    @ResponseBody
    @RequestMapping("/updPubman")
    public String updPubman(Integer circularId ,String circularTitle,String circularLabel,String domoinName,String departmentName,String circularContent,String projectName,String rankName){
//        List<Map<String,Object>> list = bannerService.updNotmanrepeat(circularId,circularTitle,circularLabel,regionName,domoinName,departmentName,circularContent,projectName,rankName);
//        if (list.size()>0){
//            return "202";
//        }else {
        //获取领域id（李易衡）
        Integer circularDomoinld = bannerService.selDomoin(domoinName);
        //获取部门id（李易衡）
        Integer circularDepartmentld = bannerService.seldepartment(departmentName);
        //获取项目id（李易衡）
        Integer circularProjectid = bannerService.selproject(projectName);
        //获取级别id（李易衡）
        Integer circularRankld = bannerService.selrank(rankName);
        //修改公式（李易衡）
        Integer code = bannerService.updPubman(circularId,circularTitle,circularLabel,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.updpuLoge(username);
            return "200";
        }else {
            return "201";
            // }
        }
    }


    //批量删除公示
    @ResponseBody
    @RequestMapping("/delPubByIds")
    public ViewJsonObject<Map<String,Object>> delPubByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delPubByIds(list);
    }

    //添加公示（李易衡）
    @ResponseBody
    @RequestMapping("/addPubman")
    public String addPubman(String circularTitle, String circularLabel, String domoinName, String departmentName, String circularContent, String projectName, String rankName, Date time){
//        List<Map<String,Object>> list = bannerService.updNotmanrepeat(circularId,circularTitle,circularLabel,regionName,domoinName,departmentName,circularContent,projectName,rankName);
//        if (list.size()>0){
//            return "202";
//        }else {
        //获取领域id（李易衡）
        Integer circularDomoinld = bannerService.selDomoin(domoinName);
        //获取部门id（李易衡）
        Integer circularDepartmentld = bannerService.seldepartment(departmentName);
        //获取项目id（李易衡）
        Integer circularProjectid = bannerService.selproject(projectName);
        //获取级别id（李易衡）
        Integer circularRankld = bannerService.selrank(rankName);
        //添加公示（李易衡）
        Integer code = bannerService.addPubman(circularTitle,circularLabel,circularDomoinld,circularDepartmentld,circularContent,circularProjectid,circularRankld,time);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.addpuLoge(username);
            return "200";
        }else {
            return "201";
            // }
        }
    }


    //删除公示（李易衡）
    @ResponseBody
    @RequestMapping("/delPubman")
    public String delPubman(Integer circularId){
        Integer code = bannerService.delPubman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delpuLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //停用公式（李易衡）
    @ResponseBody
    @RequestMapping("/stopPubman")
    public String stopPubman(Integer circularId){
        Integer code = bannerService.stopPubman(circularId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.stoppuLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //头条管理跳转（李易衡）
    @RequestMapping("/headmanjump")
    public String headmanjump(){
        return "headman";
    }
    //头条管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/headman")
    public ViewJsonObject<Map<String,Object>> headman(Integer page, Integer limit,String demoReload){
        return bannerService.headman(page,limit,demoReload);
    }


    //批量删除头条
    @ResponseBody
    @RequestMapping("/delHeaByIds")
    public ViewJsonObject<Map<String,Object>> delHeaByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delHeaByIds(list);
    }

    //标题下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selLa")
    public ArrayList<Circular> selLa(Integer circularSynthesis) {
        ArrayList<Circular> list = bannerService.selLa(circularSynthesis);
        return list;
    }

    //添加头条（李易衡）
    @ResponseBody
    @RequestMapping("/addHeadman")
    public String selLa(String circularTitle,Date time){
        //头条查重（李易衡）
        List<Headline> list = bannerService.updHeaRepeat(circularTitle);
        if (list.size()>0){
            return "202";
        }else {
            //添加头条查询标签（李易衡）
            String circularLabel = bannerService.selcir(circularTitle);
            //添加头条查询地址（李易衡）
            Integer circularRegionld = bannerService.selcirr(circularTitle);
            //添加头条（李易衡）
            Integer code = bannerService.addHeadman(circularTitle,circularLabel,time,circularRegionld);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.addheLoge(username);
                return "200";
            }else {
                return "201";
            }
        }

    }
    //修改头条（李易衡）
    @ResponseBody
    @RequestMapping("/updHeadman")
    public String updHeadman(String circularTitle,Integer headline_id){
        //头条查重（李易衡）
        List<Headline> list = bannerService.updHeaRepeat(circularTitle);
        if (list.size()>0){
            return "202";
        }else {
            //头条查询标签（李易衡）
            String circularLabel = bannerService.selcir(circularTitle);
            //头条查询地址（李易衡）
            Integer circularRegionld = bannerService.selcirr(circularTitle);
            //修改头条（李易衡）
            Integer code = bannerService.updHeadman(circularTitle,circularLabel,circularRegionld,headline_id);
            if (code>0){
                User users = (User) request.getSession().getAttribute("user");
                String username = users.getUserUsername();
                Integer loge = bannerService.updheLoge(username);
                return "200";
            }else {
                return "201";
            }
        }

    }


    //删除头条（李易衡）
    @ResponseBody
    @RequestMapping("/delHeadman")
    public String delHeadman(Integer headlineId){
        Integer code = bannerService.delHeadman(headlineId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delheLoge(username);
            return "200";
        }else {
            return "201";
        }
    }



    //项目管理跳转（李易衡）
    @RequestMapping("/promanjump")
    public String promanjump(){
        return "projman";
    }
    //项目管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/projman")
    public ViewJsonObject<Map<String,Object>> proman(Integer page, Integer limit,String demoReload,String domoin,String departments,String itemsObjname,Integer itemsState){
        //获取项目表id（李易衡）
        List<Map<String,Object>> list98= bannerService.proman();
        if (itemsState!=null){
            return bannerService.promanSel(page,limit,list98,demoReload,domoin,departments,itemsObjname,itemsState);
        }else {
            //项目管理查询（李易衡）
            ViewJsonObject<Map<String,Object>> viewJsonObject = bannerService.projman(page,limit,list98,demoReload,domoin,departments,itemsObjname);
            return viewJsonObject;
        }

    }

    //添加项目（李易衡）
    @ResponseBody
    @RequestMapping("/addprojman")
    public String addprojman(String circularTitle,String regionName,String itemContent,Date time,String departmentName,String dtdName,Integer itemObj,String domoinName,String itemWay,String itemGold,Integer itemGoMoney,String itemCondition,String itemAsk,String itemAskItem,String itemPolicy,String itemGoide,String itemManage,String ctnCircularName, String cpsCpName){
        //获取项目管理→添加的地址id（李易衡）
        Integer itemsRegionId = bannerService.selRegionId(regionName);
        //获取项目管理→添加的部门id（李易衡）
        Integer itemDepartmentId = bannerService.selDepartmentId(departmentName);
        //获取项目管理→添加的领域id（李易衡）
        Integer itemDomoinId = bannerService.selDomoinId(domoinName);
        //添加项目（李易衡）
        Integer code = bannerService.addprojman(circularTitle,itemsRegionId,time,itemDepartmentId,itemContent,dtdName,itemObj,itemDomoinId,itemWay,itemGold,itemGoMoney,itemCondition,itemAsk,itemAskItem,itemPolicy,itemGoide,itemManage);
        Integer itemId = bannerService.itemId(circularTitle);
        Integer hsnc = bannerService.hsnc(itemId,ctnCircularName);
        Integer hsnc2 = bannerService.hsnc2(itemId,cpsCpName);
        Integer hsnc3 = bannerService.hsnc3(itemId,dtdName);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.addproLoge(username);
            Integer project = bannerService.project(circularTitle);
            return "200";
        }else {
            return "201";
        }
    }


    //修改项目（李易衡）
    @ResponseBody
    @RequestMapping("/updprojman")
    public String updprojman(Integer itemId,String circularTitle,String regionName,String itemContent,Date time,String departmentName,String dtdName,Integer itemObj,String domoinName,String itemWay,String itemGold,Integer itemGoMoney,String itemCondition,String itemAsk,String itemAskItem,String itemPolicy,String itemGoide,String itemManage,String ctnCircularName, String cpsCpName){
        System.out.println("修改项目进入后台");
        //获取项目管理→添加的地址id（李易衡）
        Integer itemsRegionId = bannerService.selRegionId(regionName);
        //获取项目管理→添加的部门id（李易衡）
        Integer itemDepartmentId = bannerService.selDepartmentId(departmentName);
        //获取项目管理→添加的领域id（李易衡）
        Integer itemDomoinId = bannerService.selDomoinId(domoinName);
        //修改项目（李易衡）
        Integer code = bannerService.updprojman(itemId,circularTitle,itemsRegionId,time,itemDepartmentId,itemContent,dtdName,itemObj,itemDomoinId,itemWay,itemGold,itemGoMoney,itemCondition,itemAsk,itemAskItem,itemPolicy,itemGoide,itemManage);
        Integer hsnc = bannerService.hsnc01(itemId,ctnCircularName);
        Integer hsnc2 = bannerService.hsnc02(itemId,cpsCpName);
        Integer hsnc3 = bannerService.hsnc03(itemId,dtdName);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.updproLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //停用项目（李易衡）
    @ResponseBody
    @RequestMapping("/stopprojman")
    public String stopprojman(Integer itemId){
        Integer code = bannerService.stopprojman(itemId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.stopproLoge(username);
            return "200";
        }else {
            return "201";
        }
    }

    //删除项目（李易衡）
    @ResponseBody
    @RequestMapping("/delprojman")
    public String delprojman(Integer itemId){

        Integer code = bannerService.delprojman(itemId);
        if (code>0){
            User users = (User) request.getSession().getAttribute("user");
            String username = users.getUserUsername();
            Integer loge = bannerService.delproLoge(username);
            return "200";
        }else {
            return "201";
        }
    }


    //批量删除项目
    @ResponseBody
    @RequestMapping("/delProByIds")
    public ViewJsonObject<Map<String,Object>> delProByIds(String ids){
        List<String> list = new ArrayList<>();
        String[] str = ids.split(",");
        for (String st:str){
            list.add(st);
        }
        return bannerService.delProByIds(list);
    }

    //申报方向下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selDtd")
    public ArrayList<Map<String,Object>> selDtd() {
        ArrayList<Map<String,Object>> list = bannerService.selDtd();
        return list;
    }


    //包含通知下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selDte")
    public ArrayList<Map<String,Object>> selDte() {
        ArrayList<Map<String,Object>> list = bannerService.selDte();
        return list;
    }

    //包含政策下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selCps")
    public ArrayList<Map<String,Object>> selCps() {
        ArrayList<Map<String,Object>> list = bannerService.selCps();
        return list;
    }

    //精准配类别下拉框（李易衡）
    @ResponseBody
    @RequestMapping("/selType")
    public ArrayList<Map<String,Object>> selType(){
        ArrayList<Map<String,Object>> list = bannerService.selType();
        return list;
    }


    //日志管理跳转（李易衡）
    @RequestMapping("/logmanjump")
    public String logmanjump(){
        return "logman";
    }
    //日志管理查询（李易衡）
    @ResponseBody
    @RequestMapping("/logman")
    public ViewJsonObject<Map<String,Object>> logman(Integer page, Integer limit,String demoReload){
        return bannerService.logman(page,limit,demoReload);
    }

}